﻿using PARK.Common.Const;
using PARK.Common.Entity;
using SqlSugar;
using System;
using Yitter.IdGenerator;

namespace PARK.OAuth.Entitys
{
    /// <summary>
    /// 短信验证码记录
    /// </summary>
    [SugarTable("wc_auth_code")]
    [Tenant(ClaimConst.TENANT_ID)]
    public class WcAuthCodeEntity
    {
        /// <summary>
        /// 自然主键
        /// </summary>
        [SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
        public string Id { get; set; }
        /// <summary>
        /// RequestId
        /// </summary>
        [SugarColumn(ColumnName = "RequestId")]
        public string RequestId { get; set; }        
        /// <summary>
        /// 手机号
        /// </summary>
        [SugarColumn(ColumnName = "phone")]
        public string phone { get; set; }
        /// <summary>
        /// 手机号密文
        /// </summary>
        [SugarColumn(ColumnName = "phoneSf")]
        public string phoneSf { get; set; }
        /// <summary>
        /// 验证码
        /// </summary>
        [SugarColumn(ColumnName = "code")]
        public string code { get; set; }
        /// <summary>
        /// CreatorTime
        /// </summary>
        [SugarColumn(ColumnName = "CreatorTime")]
        public DateTime CreatorTime { get; set; }
        /// <summary>
        /// 使用状态1已使用 0未使用
        /// </summary>
        [SugarColumn(ColumnName = "IsUsed")]
        public int IsUsed { get; set; }

        /// <summary>
        /// 创建
        /// </summary>
        public virtual void Create()
        {
            this.Id = YitIdHelper.NextId().ToString();
            this.CreatorTime = DateTime.Now;
        }
    }
}
